<template>
  <el-row>
    <el-col :span="24">
      <Portlet>
        <el-form ref="searchForm" class="el-form-col search-form" :model="search">
          <el-row :gutter="15">
            <el-col :lg="4" :md="6">
              <el-form-item prop="orderNo" >
                <el-input v-model="search.orderNo" type="textarea" :rows="4" clearable
                          placeholder="服务订单号  (支持多单查询，用英文逗号分隔)"></el-input>
              </el-form-item>
            </el-col>
            <el-col :lg="4" :md="6">
              <el-form-item prop="cargoOwner">
                <el-input v-model="search.cargoOwner" placeholder="商家名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :lg="4" :md="6">
              <el-form-item prop="workerName">
                <el-input v-model="search.workerName" placeholder="师傅名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :lg="4" :md="6" class="hidden-lg-only hidden-xl-only">
              <el-form-item>
                <el-row class="search-btns" :gutter="5">
                  <el-col :span="12">
                    <el-button type="primary" :loading="searchLoading" plain native-type="submit" @click.prevent="searchFunc(search)"><span>搜索</span></el-button>
                  </el-col>
                  <el-col :span="12">
                    <el-button @click="resetFields('searchForm')" plain>重置</el-button>
                  </el-col>
                </el-row>
              </el-form-item>
            </el-col>
            <el-col :lg="4" :md="6">
              <el-form-item prop="status">
                <el-select v-model="search.status" placeholder="请选择收款状态">
                  <el-option label="未收款" value="1"></el-option>
                  <el-option label="已收款" value="2"></el-option>
                  <el-option label="已取消" value="0"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :lg="4" :md="6">
              <el-form-item prop="consigneeName">
                <el-input v-model="search.consigneeName" placeholder="用户姓名"></el-input>
              </el-form-item>
            </el-col>
            <el-col :lg="4" :md="6" class="hidden-md-only hidden-sm-only">
              <el-form-item>
                <el-row class="search-btns" :gutter="5">
                  <el-col :span="12">
                    <el-button type="primary" :loading="searchLoading" plain native-type="submit" @click.prevent="searchFunc(search)"><span>搜索</span></el-button>
                  </el-col>
                  <el-col :span="12">
                    <el-button @click="resetFields('searchForm')" plain>重置</el-button>
                  </el-col>
                </el-row>
              </el-form-item>
            </el-col>
            <el-col :lg="4" :md="6">
              <el-form-item prop="consigneePhone">
                <el-input v-model="search.consigneePhone" placeholder="用户电话"></el-input>
              </el-form-item>
            </el-col>
            <el-col :lg="4" :md="6">
              <el-form-item prop="workerPhone">
                <el-input v-model="search.workerPhone" placeholder="师傅电话"></el-input>
              </el-form-item>
            </el-col>
            <!--<el-col :span="2" class="text-center">-->
              <!--<el-button type="success" :loading="searchLoading" plain @click="searchFunc(search)">搜索</el-button>-->
            <!--</el-col>-->
            <!--<el-col :span="2" class="text-center">-->
              <!--<el-button type="primary" plain @click="isOpen = !isOpen">{{ isOpen ? '收起' : '展开' }}</el-button>-->
            <!--</el-col>-->
            <!--<el-col :span="2" class="text-center">-->
              <!--<el-button @click="resetFields" plain>重置</el-button>-->
            <!--</el-col>-->
          </el-row>
        </el-form>
      </Portlet>
    </el-col>
    <el-col :span="24">
      <BasicTable
        ref="BasicTable"
        url="/ms-warehouse-order/collectionInfo/findCollectionInfoList"
        @selection-change="selectionChange"
        :columns="columns">
      </BasicTable>
    </el-col>
  </el-row>
</template>
<script>
import {copy} from '@/utils'
import {unixTimestampFilter, decimalNumFilter} from '@/filters'
export default {
  name: 'receivablesIndex',
  components: {
  },
  data() {
    let columns = [
      {
        label: '服务订单号',
        data: 'orderNo'
      },
      {
        label: '下单时间',
        data: 'orderFoundtime',
        width: '134px',
        render(data, full) {
          return unixTimestampFilter(data)
        }
      },
      {
        label: '代收款流水号',
        data: 'collectionNumber'
      },
      {
        label: '师傅姓名',
        data: 'workerName'
      },
      {
        label: '师傅电话',
        data: 'workerPhone'
      },
      {
        label: '用户姓名',
        data: 'consigneeName'
      },
      {
        label: '用户电话',
        data: 'consigneePhone'
      },
      {
        label: '商家名称',
        data: 'cargoOwner'
      },
      {
        label: '代收总金额',
        data: 'money',
        render(data, full) {
          return decimalNumFilter(data)
        }
      },
      {
        label: '手续费',
        data: 'procedureFee',
        render(data, full) {
          return decimalNumFilter(data)
        }
      },
      {
        label: '收款状态',
        data: 'status',
        render(data, full) {
          if (full.status === '1') {
            return '未收款'
          }
          if (full.status === '2') {
            return '已收款'
          }
          if (full.status === '0') {
            return '已取消'
          }
        }
      },
      {
        label: '收款时间',
        data: 'receiverTime',
        width: '134px',
        render(data, full) {
          return unixTimestampFilter(data)
        }
      }
    ]
    return {
      cargoSourceTypes: [],
      searchLoading: false,
      serviceArr: [],
      modifyId: '',
      routeName: this.$route.name,
      search: {
        orderNo: '',
        cargoOwner: '',
        workerName: '',
        status: '',
        consigneeName: '',
        consigneePhone: '',
        workerPhone: ''
      },
      isOpen: false,
      columns
    }
  },
  computed: {
  },
  created() {
  },
  methods: {
    searchFunc(search) {
      const basicTable = this.$refs.BasicTable
      if (basicTable) {
        let params = copy(search)
        this.searchLoading = true
        basicTable.search(params).finally(_ => {
          this.searchLoading = false
        })
      }
    },
    // 重置表单
    resetFields() {
      const searchForm = this.$refs.searchForm
      if (searchForm) {
        searchForm.resetFields()
      }
    },
    // 表格刷新
    refresh() {
      this.searchFunc(this.search)
    },
    selectionChange(rows) {
      this.rows = rows
    }
  }
}
</script>
